import { UserProfilesAPI } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: '',
            coin: '',
            headImg: require('@/assets/img/monad.png')
        },
        cartTotal: ''
    },
    mutations: {
        changeuserInfo(state, payload) {
            state.userInfo = payload.userInfo;
            state.cartTotal = payload.cartTotal
        },
        initUserInfo(state) {
            state.userInfo = {
                nickName: '',
                coin: '',
                headImg: require('@/assets/img/monad.png')
            },
                state.cartTotal = ''
        }
    },
    actions: {
        async asyncchangeuserInfo({ commit }) {
            let usser = await UserProfilesAPI();
            // console.log("用户信息:", usser);
            commit("changeuserInfo", usser.data)
        }

    }
}